package com.km.core.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.File;

/**
 * <p></p>
 * Created by zhezhiyong@163.com on 2017/4/28.
 */
@Slf4j
public class PathUtils {

    private static final String PATH_TAG = "project";

    /**
     * 建立项目缓存目录
     */
    public static String initProjectTempPath() {
        String folder = System.getProperty("java.io.tmpdir", "/tmp");
        String dirPath = folder + File.separator + PATH_TAG + File.separator;
        File file = new File(dirPath);
        if (!file.exists()) {
            if (!file.mkdirs()) {
                log.error("create file path error");
            }
        }
        log.info("project tmp dir: {}", dirPath);
        return dirPath;
    }

    /**
     * 建立项目缓存目录
     */
    public static String GetProjectTempPath() {
        String folder = System.getProperty("java.io.tmpdir", "/tmp");
        return folder + File.separator + PATH_TAG + File.separator;
    }

}
